using Microsoft.AspNetCore.Mvc;
using star_questionnair.Models;
using star_questionnair.Services;
using star_questionnair.Services.impl;

namespace star_questionnair.Controllers;
[Route("crossAnalysis")]
[ApiController]
public class CrossAnalysisController : ControllerBase
{
    private readonly CrossAnalysisService _crossAnalysisService;

    public CrossAnalysisController(CrossAnalysisService crossAnalysisService)
    {
        _crossAnalysisService = crossAnalysisService;
    }

    [HttpGet("analyze")]
    public async Task<ActionResult<Dictionary<string, Dictionary<string, double>>>> CrossAnalyze([FromQuery] int xQuestionId, [FromQuery] int yQuestionId)
    {
        var result = await _crossAnalysisService.CrossAnalyzeAsync(xQuestionId, yQuestionId);
        if (result != null)
        {
            return Ok(new { success = true, data = result });
        }
        return NotFound("No data found for the given questions.");
    }
}